package com.adu.miniospringbootstarter.Entity;

/**
 * 文件类型枚举类
 */
public enum FileType {
    // 图片
    JPEG("jpeg","001"),JPG("jpg","002"),PNG("png","003"),
    GIF("gif","004"),SVG("svg","005"),ICO("ico","006"),
    JFIF("jfif","007"),
    // 音乐视频
    MP4("mp4","100"),MP3("mp3","101"),
    //压缩文件
    ZIP("zip","150"),RAR("rar","151"),
    // 文档
    XLSX("xlsx","200"),XLS("xls","201"),PPTX("pptx","202"),
    PDF("pdf","203"),DOCX("docx","204"),MD("md","205"),
    TXT("txt","206"),JSON("json","207"),HTML("html","208"),
    JS("js","209"),PPT("ppt","210"),SQL("sql","211"),
    //程序
    EXE("exe","300"),MSI("msi","301"),JAR("jar","302"),
    //其他
    ISO("iso","400"),CRX("crx","401");

    private String type;
    private String index;

    public static String getIndexByType(String type){
        for(FileType temp:FileType.values()){
            if(temp.type.equals(type)){
                return temp.getIndex();
            }
        }
        return "000";
    }
    public static String getTypeByIndex(String index){
        for(FileType temp:FileType.values()){
            if(temp.index.equals(index)){
                return temp.getType();
            }
        }
        return "";
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    private FileType(String type, String index){
        this.type=type;
        this.index=index;
    }

}
